package com.chennan.algorithm.leetcode.three;

import java.util.*;
import java.util.stream.Collectors;

/**
 * @author chennan
 * @create 2022-03
 */
public class isValidSudoku {

    public boolean isValidSudoku(char[][] board) {
        int length = board.length;
        //前一个数代表第几行 或者第几列，后一个数代表
        int[][] line = new int[length][length];
        int[][] row = new int[length][length];
        int[][] block = new int[length][length];
        for (int i = 0; i < length; i++) {
            int length1 = board[i].length;
            for (int j = 0; j < length1; j++) {
                if('.'==board[i][j]){
                    continue;
                }
                int number = Integer.parseInt(board[i][j]+"")-1;
                int k = i/3*3+j/3;
                if(line[i][number]==1||row[j][number]==1||block[k][number]==1){
                    return false;
                }
                line[i][number]=row[j][number]=block[k][number]=1;
            }
        }
        return true;
    }

    public static void main(String[] args) {
        System.out.println("b".charAt(0)-'a');
        System.out.println("gg".indexOf('g'));
    }
}
